function notify(msg) {
    var create_notify = function(msg) {
        var id ='notification' + parseInt(Math.random() * 1000); 
        var str = '<div class="notification" id="'+ id +'">'
            + '<a href="#" class="notification-close-btn"></a>'
            + msg +'</div>';
        return [id, str];
    }
    var notification = create_notify(msg);
    $('#notify-area').append(notification[1]);
    var id = '#' + notification[0];
    $(id).hover(function () {
            $(this).fadeTo('fast', 0.25);
        }, 
        function () {
            $(this).fadeTo('fast', 0.75);
        });
    $(id).find('a').click(function () {
            $(id).fadeOut('slow');
        })
    $(id).boxShadow(0, 0, 10, '#000');
    window.setTimeout(function () {
            $(id).fadeOut('slow');
            }, 7000);
    window.setTimeout(function () {
            $(id).remove();
            }, 10000);
    $(id).fadeIn('slow');
}
function switch_toolbar(bar, searchbar) {
    $('#tool-bars .tool-bar').hide();
    $(bar).show();
    if (searchbar)
        $('#search-bar').show();
    else 
        $('#search-bar').hide();
}

function switch_page(page){
    var fade_out_all = function () {
        if (page == global.crr_page){
            return ;
        }
        $('#content').find('.content-view').each(function () {
            $(this).hide();
        });
    }
    if (page == 0) {
        //start page
        global.modified_block_ids = {};
        global.crr_note_id = -1;
        global.crr_note_title = '';
        fade_out_all();
        $('#start-page').fadeIn();
    } else if (page == 1) {
        //notebook view page
        global.modified_block_ids = {};
        global.crr_note_id = -1;
        global.crr_note_title = '';
        fade_out_all();
        $('#notebook-view').fadeIn();

        switch_toolbar('#notebook-view-bar', true);
    } else if (page == 2) {
        //note view page
        note_view.save_status();
        $('#note-title').text(global.crr_note_title);
        fade_out_all();
        $('#note-view').fadeIn();

        switch_toolbar('#note-view-bar', true);
    } else if (page == 2) {
        //search result page
    }
    global.crr_page = page;
}


function apply_filter(filter_text) {
    $('.note-item').each(function () {
        if ($(this).text().search(filter_text) == -1) {
            $(this).fadeOut();
        } else {
            $(this).fadeIn();
        }
    });
}
 



